package com.sykj.controller;

import com.sykj.bean.Classes;
import com.sykj.bean.Student;
import com.sykj.service.ClassesService;
import com.sykj.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("student")
public class SController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private ClassesService classesService;

    @RequestMapping("/query")
    public Map index(Student student){
        List<Student> student2 = studentService.index(student);
        List<Classes> classes = classesService.show();

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("student2",student2);
        map.put("classes",classes);
        return map;
    }

    @RequestMapping("delete")
    public void delete(Student student){
        studentService.delete(student);
    }

    @RequestMapping("save")
    public void save(Student student){
        studentService.save(student);
    }
}
